/*
* BankApplication
*
* r1
*
* GNU General Public License v3.0
*/

package com.acme.bankapp;

import com.acme.bankapp.domain.bank.*;
import com.acme.bankapp.service.bank.*;

public class BankApplication {

	private static Bank bank = new Bank();
	private static BankService bankService = new BankService();
	
	private static void addClient(String firstName, String lastName, Gender gender, int age, AbstractAccount... accounts) {
		Client client;
		
		client = new Client(firstName, lastName, gender, age);
		for(AbstractAccount a : accounts) {
			client.getAccounts().add(a);
		}
		BankApplication.bankService.addClient(BankApplication.bank, client);
	}
	
	private static void printMaximumAmountToWithdraw(Bank bank) {
		BankApplication.bankService.printMaximumAmountToWithdraw(bank);
	}
	
	private static void calculateInterests(Bank bank) {
		BankApplication.bankService.calculateInterests(bank);
	}
	
	public static void main(String[] args) {

		addClient("Vladimir", "Putin", Gender.MALE, 40, new CheckingAccount(0, 1000000));
		addClient("Galka", "Pugacheva", Gender.FEMALE, 23, new SavingsAccount(100));
		addClient("Ya", "Ya", Gender.MALE, 38, new CheckingAccount(200, 1000));
		addClient("Noob", "Anonymous", Gender.FEMALE, 5, new SavingsAccount(300000));

		calculateInterests(BankApplication.bank);
		
		modifyBank(BankApplication.bank);
		
		printMaximumAmountToWithdraw(BankApplication.bank);
	}
	
	private static void modifyBank(Bank bank) {
		bank.getClients().get(0).getAccounts().get(0).withdraw(100);
		bank.getClients().get(1).getAccounts().get(0).deposit(100);
		bank.getClients().get(2).getAccounts().get(0).withdraw(25);
		bank.getClients().get(2).getAccounts().get(0).deposit(598);
		bank.getClients().get(2).getAccounts().get(0).withdraw(478);
	}
	
}
